<%@ page isELIgnored="true" %>

<script id="peer_tpl" type="text/x-blacktea-template">	
	<a class="cell" target="hotweb_${username}" href="${fn:appbase}peer=${username}">
		<img src="http://hotwebproxy.appspot.com/assets/opt/tango-icon-theme/22x22/apps/${fn:status}" />
		<div class="caption">${fn:label}</div>
	</a>
</script>

<script type="text/javascript">
function formatPeer(data, app) {
	function baseQueryLink(l) {
		var idx = l.indexOf('?');
		if (idx == -1) {
			return l + '?';
		}
		var len_1 = l.length - 1;
		if (idx < len_1) {
			return l + '&';
		}
		//idx == len_1
		return l;
	}
	function formatLabel(label) {
		var idx = label.indexOf('@');
		return idx == -1 ? label : label.substring(0, idx) + '<br />' + label.substring(idx);
	}
	var tid = 'peer_tpl', br = '<br style="clear: both;" />', max = 7,
		fn = { 
			appbase: baseQueryLink(app ? app : '/home/?type=html' ),
			status: function () {
				return this.status > 0 ? 'system-users.png' : 'system-users-off.png';
			},
			label: function () {
				var l = this.name || this.username;
				return formatLabel(l);
			}
		};
	return blacktea(tid, data.peers, fn, br, max);
}
</script>